#define _CRT_SECURE_NO_WARNINGS
#include"SLnkList.h"

void Test1()
{
	SLTNode* p = NULL;

	PushBackSLT(&p, 1);
	PushBackSLT(&p, 2);
	PushBackSLT(&p, 3);
	PushBackSLT(&p, 4);
	PushBackSLT(&p, 5);

	PrintSLTNode(p);

	PopBackSLT(&p);
	PopBackSLT(&p);
	PopBackSLT(&p);
	PopBackSLT(&p);

	PrintSLTNode(p);

	
	DestroySLTNode(p);
	p = NULL;
	PrintSLTNode(p);

}

void Test2()
{
	SLTNode* p = NULL;

	PushFrontSLT(&p, 1);
	PushFrontSLT(&p, 2);
	PushFrontSLT(&p, 3);
	PushFrontSLT(&p, 4);
	PushFrontSLT(&p, 5);

	PrintSLTNode(p);
	
	PopFrontSLT(&p);
	PopFrontSLT(&p);
	PopFrontSLT(&p);
	PopFrontSLT(&p);

	PrintSLTNode(p);

	
	DestroySLTNode(p);
	p = NULL;
	PrintSLTNode(p);

}

void Test3()
{
	SLTNode* p = NULL;
	PushBackSLT(&p, 1);
	PushBackSLT(&p, 2);
	PushBackSLT(&p, 3);
	PrintSLTNode(p);

	SLTNode* pos1 = FindSLT(p, 1);
	SLTNode* pos2 = FindSLT(p, 3);
	InsertSLTBefore(&p, pos1, 4);
	InsertSLTBefore(&p, pos2, 5);
	PrintSLTNode(p);

	SLTNode* pos3 = FindSLT(p, 5);
	SLTNode* pos4 = FindSLT(p, 4);
	InsertSLTAfter(pos3, 6);
	InsertSLTAfter(pos4, 7);

	PrintSLTNode(p);

	SLTNode* pos5 = FindSLT(p, 4);
	SLTNode* pos6 = FindSLT(p, 2);
	SLTNode* pos7 = FindSLT(p, 3);

	EraseSLT(&p, pos5);
	pos5 = NULL;
	EraseSLT(&p, pos6);
	pos6 = NULL;
	EraseSLT(&p, pos7);
	pos7 = NULL;
	PrintSLTNode(p);

	
	DestroySLTNode(p);
	p = NULL;
	PrintSLTNode(p);

}

int main()
{
	Test3();
	return 0;
}